package com.lxmes.pm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.pm.domain.AKyTeam;
import com.lxmes.pm.service.IAKyTeamService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 科研团队Controller
 * 
 * @author zhangzhiyu
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/pm/kyTeam")
public class AKyTeamController extends BaseController
{
    @Autowired
    private IAKyTeamService aKyTeamService;

    /**
     * 查询科研团队列表
     */
    @PreAuthorize("@ss.hasPermi('pm:kyTeam:list')")
    @GetMapping("/list")
    public TableDataInfo list(AKyTeam aKyTeam)
    {
        startPage();
        List<AKyTeam> list = aKyTeamService.selectAKyTeamList(aKyTeam);
        return getDataTable(list);
    }

    /**
     * 导出科研团队列表
     */
    @PreAuthorize("@ss.hasPermi('pm:kyTeam:export')")
    @Log(title = "科研团队", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AKyTeam aKyTeam)
    {
        List<AKyTeam> list = aKyTeamService.selectAKyTeamList(aKyTeam);
        ExcelUtil<AKyTeam> util = new ExcelUtil<AKyTeam>(AKyTeam.class);
        util.exportExcel(response, list, "科研团队数据");
    }

    /**
     * 获取科研团队详细信息
     */
    @PreAuthorize("@ss.hasPermi('pm:kyTeam:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aKyTeamService.selectAKyTeamById(id));
    }

    /**
     * 新增科研团队
     */
    @PreAuthorize("@ss.hasPermi('pm:kyTeam:add')")
    @Log(title = "科研团队", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AKyTeam aKyTeam)
    {
        return toAjax(aKyTeamService.insertAKyTeam(aKyTeam));
    }

    /**
     * 修改科研团队
     */
    @PreAuthorize("@ss.hasPermi('pm:kyTeam:edit')")
    @Log(title = "科研团队", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AKyTeam aKyTeam)
    {
        return toAjax(aKyTeamService.updateAKyTeam(aKyTeam));
    }

    /**
     * 删除科研团队
     */
    @PreAuthorize("@ss.hasPermi('pm:kyTeam:remove')")
    @Log(title = "科研团队", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aKyTeamService.deleteAKyTeamByIds(ids));
    }
}
